// pages/qualityControl/definQuality/detailDefin/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    serialOrLotNumber:"",
    qcPeriod:"",
    qcItemCategory:"",
    qcItem:"",
    qcSubItem:"",
    thresholdRange:"",
    unit:"",
    chartDisplay:"",
    useQcEquipment:"",
    param:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self = this
     const eventChannel = this.getOpenerEventChannel();
		// 监听 index页面定义的toHome 事件
		eventChannel.on('todetail', (res) => {
      this.setData({
        serialOrLotNumber:res.item.serialOrLotNumber,
        qcPeriod:res.item.qcPeriod,
        qcItemCategory:res.item.qcItemCategory,
        qcItem:res.item.qcItem,
        qcSubItem:res.item.qcSubItem,
        thresholdRange:res.item.thresholdRange,
        unit:res.item.unit,
        chartDisplay:res.item.chartDisplayText,
        useQcEquipment:res.item.useQcEquipment==1?"是":"否",
        param:res
      })
      console.log(res,'页面传值')
    })

  },
  removeData(){
    let self = this
    wx.showModal({
      title: '提示',
      content: '确定删除？',
      success: function (res) {
        if (res.confirm) {
          self
          .axios
          .remove("QcProjectEquipmentConfig", self.data.param.item.id)
          .then(function () {
            wx.showToast({
              title: '删除成功',
              icon: 'succes',
              duration: 1000,
              mask:true
          })
          wx.navigateBack({
            delta: 1
          })

          })
          .catch(function (response) {
            self.$notify(response.data.msg, "error");
          });
          console.log('确定')
        } else {
          console.log('取消')
        }
      }
    })
  },
  edtion(){
    let self = this
    wx.navigateTo({
      url: '../edtionDefin/index',
          success:function(res){
           res.eventChannel.emit('toedtion',{item:self.data.param.item})
    }
  })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})